package com.sduept.nwld.dataserver.manager.rota;

import com.sduept.core.dao.SuperDAO;
import com.sduept.nwld.dataserver.model.rota.RotaOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * 轮值Manager
 * @author leodexin
 *
 */
@Service
public class RotaOrderManager {
	
	@Autowired
	SuperDAO sdao;
	/**
	 * 生成一条轮值记录
	 * @param rotaOrder
	 * @return
	 */
	public RotaOrder createRotaOrder(RotaOrder rotaOrder){
		return sdao.create(rotaOrder, RotaOrder.class);
	}
	/**
	 * 编辑一条轮值记录
	 * @param rotaOrder
	 * @return
	 */
	public RotaOrder updateRotaOrder(RotaOrder rotaOrder){
		return sdao.update(rotaOrder, RotaOrder.class);
	}
	/**
	 * 根据id删除一条轮值记录
	 * @param id
	 */
	public void delRotaRota(String id){
		 sdao.delete(id, RotaOrder.class);
	}
	/**
	 * 获取所有轮值记录
	 * @return
	 */
	public List<RotaOrder> findAllRotaOrder(){
		return sdao.findByComplexCondition("from RotaOrder order by rotaOrder", RotaOrder.class);
	}
	
	/**
	 * 获取所有轮值记录
	 * @return
	 */
	public List<RotaOrder> findAllRotaOrderByOrder(){
		return sdao.findByComplexCondition("from RotaOrder order by rotaOrder", RotaOrder.class);
	}
	
	/**
	 * 按姓氏逆序获取所有轮值记录
	 * @return
	 */
	public List<RotaOrder> findAllRotaOrderByOrderDesc(){
		return sdao.findByComplexCondition("from RotaOrder order by rotaOrder desc", RotaOrder.class);
	}
	/**
	 * 获取轮值游标为1的轮值信息
	 * 1 当值  0 不当值
	 * @return
	 */
	public List<RotaOrder> findCursorisBeOnDutyRotaOrder(){
		return sdao.findByCondition("cursor=?", new Object[]{1}, RotaOrder.class);
	}

}
